#include <iostream>
#include <list>
#include <string>

using namespace std;

void f(string s) {
    int len = s.size();

    list<char> L;
    list<char>::iterator it = L.begin();

    for(int i = 0; i < len; i++) {
        if('[' == s[i]) {
            it = L.begin();
        } else if(']' == s[i]) {
            it = L.end();
        } else {
            it = L.insert(it, s[i]);
            it++;
        }
    }
    
    for(it = L.begin(); it != L.end(); it++) {
        cout << *it;
    }
    cout << "\n";
    s.clear();

}

int main()
{

    string s;
    while(cin >> s) {
        f(s);
    }

    return 0;
}

